﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DNNspot.Sitemap
{
    public partial class SkinObject : ModuleBase
    {
        public string ShowHiddenMenuItems { get; set; }
        public string SitemapLevel { get; set; }
        public string SitemapStart { get; set; }
        public string PortalIdToUse { get; set; }
        public string ExcludedTabs { get; set; }
        public string IncludedTabs { get; set; }
        public string PortalAliasToUse { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            _ShowHiddenMenuItems = !String.IsNullOrEmpty(ShowHiddenMenuItems) ? Convert.ToBoolean(ShowHiddenMenuItems) : false;
            _SitemapLevel = !String.IsNullOrEmpty(SitemapLevel) ? Convert.ToInt32(SitemapLevel) : 0;
            _SitemapStart = !String.IsNullOrEmpty(SitemapStart) ? Convert.ToInt32(SitemapStart) : -1;
            _PortalId = !String.IsNullOrEmpty(PortalIdToUse) ? Convert.ToInt32(PortalIdToUse) : PortalId;
            _PortalAlias = !String.IsNullOrEmpty(PortalAliasToUse) ? Convert.ToString(PortalAliasToUse) : String.Empty;
            _ExcludedTabs = ExcludedTabs != null ? ExcludedTabs.Split(',') : new string[] { };
            _IncludedTabs = IncludedTabs != null ? IncludedTabs.Split(',') : new string[] { };

            if (_SitemapStart == 0)
                _SitemapStart = -1;

            try
            {
                string tabidexclude = Convert.ToString(ExcludedTabs);
                if (!string.IsNullOrEmpty(tabidexclude))
                {
                    _ExcludedTabs = tabidexclude.Split(',');
                }
            }
            catch (Exception ex)
            {


            }


            litSitemapOutput.Text = GenerateSitemap(PortalSettings.ActiveTab);
        }
    }
}